<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="button" value="0">
  <button id="btn1">+</button>
  <button id="btn2">-</button>
</body>
<script>
  var t1 = document.getElementById('btn1')
  var t2 = document.getElementById('btn2')
  var p = document.querySelector('input'), i = 0
  t1.onclick = function () {
    p.value = i++
  }
  t2.onclick = function () {
    if (p.value == 0) return 0
    p.value = i--
  }
</script>

</html>